"""Make model3d_uploads user_id and product_id nullable

Revision ID: 002
Revises: 001_enhanced_3d_model_and_shopify_integration
Create Date: 2025-10-23 15:30:00.000000

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '002'
down_revision = '001'
branch_labels = None
depends_on = None


def upgrade() -> None:
    # 修改 user_id 字段为可空
    with op.batch_alter_table('model3d_uploads') as batch_op:
        batch_op.alter_column('user_id', nullable=True, existing_type=sa.Integer())
        batch_op.alter_column('product_id', nullable=True, existing_type=sa.Integer())


def downgrade() -> None:
    # 恢复 user_id 和 product_id 为非空
    with op.batch_alter_table('model3d_uploads') as batch_op:
        batch_op.alter_column('user_id', nullable=False, existing_type=sa.Integer())
        batch_op.alter_column('product_id', nullable=False, existing_type=sa.Integer())